package finger.test;

import finger.dao.UserDao;
import finger.dao.impl.UserDaoimpl;
import finger.domain.User;
import finger.service.UserService;
import finger.service.impl.UserServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class test {
    @Test
    public void test1() {
        List list = new ArrayList();
        Person person = new Maie();
        list.add(person);
        Object o = list.get(0);
        System.out.println(o==person);
    }

    UserDao dao = new UserDaoimpl();

    @Test
    public void test2() {
        User admin = dao.queryUserForUsername("admi");
        if (admin == null) {
            System.out.println("用户名不存在");
        } else {
            System.out.println("用户名已存在");
        }
    }

    @Test
    public void test3() {
        User user = dao.queryUserForUsernameAndPassword("admin", "admin1");
        if (user == null) {
            System.out.println("用户名或密码错误");
        } else {
            System.out.println("登录成功");
        }
    }

    @Test
    public void test4() {
        int save = dao.save(new User("zhaoshichao", "123456", "Email"));
        if (save == -1) {
            System.out.println("用户名已存在");
        } else {
            System.out.println("添加成功");
        }
    }

    UserService service = new UserServiceImpl();
    @Test
    public void test5() {
        User user = new User("haha", "abc123", "email");
        service.registUser(user);


    }
    @Test
    public void test6() {
        User user = service.loginUser("haha", "abc123");
        System.out.println(user);
    }
    @Test
    public void test7() {
        if (service.existsUser("haha1")) {
            System.out.println("用户存在");
        } else {
            System.out.println("用户不存在");
        }
    }
    @Test
    public void test(){

        System.out.println();
    }

}
